#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 1e5+10;
long long a[maxn];
long long b[maxn];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		long long n,m;
		long long sum = 0;
		long long ans = 0;
		int cnt = 0;
		cin>>n>>m;
		for(int i = 0;i<n;i++)
		{
			cin>>a[i];
			if(a[i]>=m)
			{
				sum += (a[i]-m);
				ans++;
			}
			else b[cnt++] = a[i];
		}
		//printf("****%d\n",sum);
		sort(b,b+cnt);
		for(int i = cnt-1;i>=0;i--)
		{
			//printf("***%d\n",i);
			if(sum-(m-b[i])>=0)
			{
				ans++;
				sum -= (m-b[i]);
			}
			else break;
		}
		cout<<ans<<endl; 	 
	}
}
